<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>首次修改密码</title>
    <link rel="stylesheet" href="__TPL__/frame/layui/css/layui.css">
    <link rel="stylesheet" href="__TPL__/frame/static/css/style.css">
    <link rel="icon" href="__TPL__/frame/static/image/code.png">
</head>
<body class="body login-body">
<div class="login-box">
    <h3>密码注意事项:</h3>
    <hr>
    <div style="margin-left: 40px">
        <h4>1、不要让密码和账户名称相同。</h4>
        <h4>2、不要用手机号、账户、身份证的一部分作为密码。</h4>
        <h4>3、不将有规律的字符和数字作为密码。</h4>
        <h4>4、最好一个账户一个密码。</h4>
        <h4>5、密码不要与常用的软件账户密码相同。</h4>
        <h4>6、密码要设置的复杂。</h4>
    </div>
    <br><br>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">旧密码</label>
            <div class="layui-input-inline">
                <input type="password" name="id" value="{$info.id}" hidden>
                <input type="password" name="old_pwd" autocomplete="off" placeholder="请输入旧密码"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-inline">
                <input type="password" id="pwd1" lay-verify="pwd_check" autocomplete="off"
                       placeholder="请输入密码" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">再次输入</label>
            <div class="layui-input-inline">
                <input type="password" id="pwd2" name="new_pwd" lay-verify="pwd_check|check" autocomplete="off"
                       placeholder="请再次输入密码" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="edit_submit">立即修改</button>
            </div>
        </div>
    </form>
</div>
<script src="__TPL__/frame/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;
        form.on('submit(edit_submit)', function (data) {
            $.ajax({
                url: '{:url("Login/firstEditPwdPost")}',
                type: 'post',
                data: data.field,
                dataType: 'json',
                success: function (data) {
                    if (data.code === 1) {
                        location.href = "{:url('Index/index')}"
                    } else {
                        layer.msg(data.msg, {icon: 1, time: 2000})
                    }
                }
            });
            return false;
        })
        //表单验证
        form.verify({
            pwd_check: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value.length < 8) {
                    return '密码不能小于8位';
                }
                if (/(^\_)|(\__)|(\_+$)/.test(value)) {
                    return '密码首尾不能出现下划线\'_\'';
                }
            },
            check: function (value, item) {
                var pwd1 = $('#pwd1').val();
                var pwd2 = $('#pwd2').val();
                if (pwd1 !== pwd2) {
                    return '两次密码输入不同';
                }
            }
        })
        ;
    })
    ;
</script>
</body>
</html>